import 'package:flutter/material.dart';

class AnimApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'change View',
      theme: new ThemeData(primaryColor: Colors.amberAccent[400]),
      home: new AnimWidget(title: 'anim title'),
    );
  }
}

class AnimWidget extends StatefulWidget {
  AnimWidget({Key key, this.title}) : super(key: key);

  String title;

  @override
  State<StatefulWidget> createState() {
    return new AnimState();
  }
}

class AnimState extends State<AnimWidget> with TickerProviderStateMixin {
  AnimationController animController;
  CurvedAnimation curve;

  @override
  void initState() {
    super.initState();
    animController = new AnimationController(
        duration: const Duration(microseconds: 2000), vsync: this);
    curve = new CurvedAnimation(parent: animController, curve: Curves.easeIn);
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(
          child: new Container(
              child: new FadeTransition(
                  opacity: curve,
                  child: new FlutterLogo(
                    size: 100.0,
                  )))),
      floatingActionButton: new FloatingActionButton(
        tooltip: 'Fade',
        child: new Icon(Icons.brush),
        onPressed: () {
          animController.forward();
        },
      ),
    );
  }
}
